package com.example.erp;

import java.util.List;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ai.vectorstore.SimpleVectorStore;
import org.springframework.ai.vectorstore.VectorStore;

@Configuration
public class RagConfig {

	@Bean
	ChatClient chatClient(ChatClient.Builder builder) {
		return builder.defaultSystem("你是一名Java开发专家，对用户的使用需求做出解答").build();
	}

	@Bean
	VectorStore vectorStore(EmbeddingModel embeddingModel) {
		SimpleVectorStore simplevectorstore = SimpleVectorStore.builder(embeddingModel).build();
		// 生成一个说明的文档
		List<Document> documents = List.of(new Document("""
														产品说明:
														名称:Java开发语言
														产品描述:Java是一种面向对象开发语言。
														主要特性:
														1.封装
														2.继承
														3.多态
														"""));
		simplevectorstore.add(documents);
		return simplevectorstore;
	}
}
